<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>配置</title>
    <style>
        .configTitle{
            width: 140px;
        }
        .configInput{
            width: 300px;
            display: inline;
        }
    </style>
</head>
<body>
<div style="margin-left: 50px;margin-top: 50px;">
    <form id="configForm">
        <P class="configTitle">当前位置: </P><input name="channel" value="${config.channel}" class="configInput"><br/>
        <P class="configTitle">车牌机IP: </P><input name="cameraIp" value="${config.cameraIp}" class="configInput"><br/>
        <P class="configTitle">车牌机端口: </P><input name="cameraPort" value="${config.cameraPort}" class="configInput"><br/>
        <P class="configTitle">用户名: </P><input name="cameraUserName" value="${config.cameraUserName}" class="configInput"><br/>
        <P class="configTitle">密码: </P><input name="cameraPassword" value="${config.cameraPassword}" class="configInput"><br/>
        <P class="configTitle">道闸序号: </P><input name="cameraGate" value="${config.cameraGate}" class="configInput"><br/>
        <P class="configTitle">进场域名: </P><input name="entryBillAddr" value="${config.entryBillAddr}" class="configInput"><br/>
        <P class="configTitle">地磅域名: </P><input name="weightAddr" value="${config.weightAddr}" class="configInput"><br/>
        <P class="configTitle">地磅获取次数: </P><input name="weightGetNum" value="${config.weightGetNum}" class="configInput"><br/>
        <P class="configTitle">地磅获取频率(ms): </P><input name="weightGetFrequence" value="${config.weightGetFrequence}" class="configInput"><br/>
    </form>
    <button style="margin-top: 20px;width: 50px;" id="btnPost">提交</button>
</div>
</body>
</html>
<script src="/static/js/jquery-3.3.1.min.js"></script>
<script>
    $(function(){
        $("#btnPost").on("click",function(){
            let data = {};
            var value = $('#configForm').serializeArray();
            $.each(value, function (index, item) {
                data[item.name] = item.value;
            });
            let json = JSON.stringify(data);
            console.log('json : ',json);
            $.ajax({
                type: 'post',
                url: 'http://localhost:8997/lpr/setConfig',
                data: json,
                dataType: 'json',
                contentType: "application/json; charset=utf-8",
                success:function(res){
                    console.log(res);
                    if(res.code == '200'){
                        alert("保存成功");
                        window.location.reload();
                    }else{
                        alert("保存失败");
                    }
                }
            });
        })
    })
</script>
